// Registry.cpp: implementation of the CRegistry class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Registry.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CRegistry::CRegistry()
{

}

CRegistry::~CRegistry()
{

}

BOOL CRegistry::QueryValue(const HKEY hSyntekDbOption, LPCTSTR lpValueName, LPTSTR &pszData)
{
	DWORD dwType= 0;
	DWORD dwValueLen= 0;
		if (ERROR_SUCCESS != RegQueryValueEx(hSyntekDbOption, lpValueName, NULL, &dwType, NULL, &dwValueLen))
			return FALSE;
	if (REG_SZ != dwType)
		return FALSE;

	pszData = new char[dwValueLen];
		memset(pszData, 0, dwValueLen);

	if (ERROR_SUCCESS != RegQueryValueEx(hSyntekDbOption, lpValueName, NULL, NULL, reinterpret_cast<LPBYTE>(pszData), &dwValueLen))
		return FALSE;

	pszData[dwValueLen-1] = '\0';

	return TRUE;
}

BOOL CRegistry::QueryValue(const HKEY hSyntekDbOption, LPCTSTR lpValueName, DWORD &dwData)
{
	DWORD dwType= 0;
	DWORD dwValueLen= 0;
		if (ERROR_SUCCESS != RegQueryValueEx(hSyntekDbOption, lpValueName, NULL, &dwType, NULL, &dwValueLen))
			return FALSE;
	if ((REG_DWORD != dwType) || (sizeof(DWORD) != dwValueLen))
		return FALSE;

	if (ERROR_SUCCESS != RegQueryValueEx(hSyntekDbOption, lpValueName, NULL, NULL, reinterpret_cast<LPBYTE>(&dwData), &dwValueLen))
		return FALSE;

	return TRUE;
}
